package cn.uce.cc.rest.control;

import cn.uce.cc.api.service.biz.ICcosRoutTrackBiz;
import cn.uce.common.utils.DateUtil;
import cn.uce.web.common.base.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.*;

 /**
   * 路由与物流轨迹接口
   * @Author liupan
   * @Description
   * @Date  2020-07-01 11:37
   */
@Controller
@RequestMapping(value = "/ccos/routTrack")
public class CcosRoutTrackController extends BaseController {

    @Resource
    private ICcosRoutTrackBiz ccosRoutTrackBiz;

    /**
     * 对话框查询路由时效
     * 对话框查询路由时效
     * @param startPoint
     * @param endPoint
     * @param proType
     * @param newBillTime
     * @return
     */
    @RequestMapping(value = "/routDetilInfo", method = RequestMethod.POST)
    @ResponseBody
    public Map<String,Object> routDetilInfo(String startPoint, String endPoint, String proType, String newBillTime) {
        try {
            Map<String, Object> map = new HashMap();
            map.put("sourceZoneCode", startPoint);
            map.put("orderTime", DateUtil.parseString(newBillTime, "yyyy-MM-dd HH:mm:ss").getTime());
            map.put("productCode", proType);
            map.put("destZoneCode", endPoint);
            return returnSuccess(ccosRoutTrackBiz.routDetilInfo(map));
        } catch (Exception e) {
            logger.error("通过起始网点查询路由信息出现异常：" + e);
        }
        return returnError("起始网点查询路由信息出现异常");
    }


     //rout_trakrout_protype 查询产品类型
     /**
      * @MethodName getrouttrak
      * @return routtrak
      */
     @RequestMapping(value = "/getrouttrakType", method = RequestMethod.POST)
     @ResponseBody
     public Map<String, Object> getrouttrakType(){
         try {
             return returnSuccess( ccosRoutTrackBiz.getrouttrakType());
         } catch (Exception e) {
             logger.error("路由时效产品类型初始化失败：" +e);
         }
         return null;
     }


     /**
      * @MethodName getrouttrak
      * @return routtrak
      */
     @RequestMapping(value = "/getRoutingLocusInfoByWBNo", method = RequestMethod.POST)
     @ResponseBody
     public Map<String, Object> getRoutingLocusInfoByWBNo(String wayNum){
         try {
             return returnSuccess(ccosRoutTrackBiz.getRoutingLocusInfoByWBNo(wayNum));
         } catch (Exception e) {
             logger.error("路由时效产品类型初始化失败：" +e);
         }
         return null;
     }
}
